﻿/********************************************************
 * 类名：CommonManageHandler.cs
 * 功能：
 *   ver	变更日		作者			变更内容
 * ────────────────────────────────────────
 *   V01.0	2013-12-23	李波			初版
 *
 * Copyright (c) 2013，李波版权所有
 ********************************************************/
using System;
using System.Web;
using PSS.BLL.CommonManage;
using PSS.Entity.InitPurManage;
using PSS.Utility;

namespace PSS.WebSite.Service
{
    /// <summary>
    /// CommonManageHandler 的摘要说明
    /// </summary>
    public class CommonManageHandler : IHttpHandler
    {
        private readonly CodeBLL _codeBll=new CodeBLL();

        public void ProcessRequest(HttpContext context)
        {
            try
            {
                var action = StrRequest.GetQueryString("action");
                if (string.IsNullOrEmpty(action)) return;
                var method = this.GetType().GetMethod(action);
                if (method == null) return;
                object[] parameters = { context };
                method.Invoke(this, parameters);
            }
            catch (Exception ex)
            {
                EventsLog.WriteLog("程序错误：" + ex.Message);
            }
        }

        #region 单据编号
        /// <summary>
        /// 采购单号
        /// </summary>
        /// <param name="context"></param>
        public void GetFBillNo(HttpContext context)
        {
            var json = _codeBll.GetFBillNo();
            context.Response.Write(json);
            context.Response.End();
        }
        /// <summary>
        /// 收款单号
        /// </summary>
        /// <param name="context"></param>
        public void GetReceiptSingleNo(HttpContext context)
        {
            var json = _codeBll.GetReceiptSingleNo();
            context.Response.Write(json);
            context.Response.End();
        }

        /// <summary>
        /// 付款单号
        /// </summary>
        /// <param name="context"></param>
        public void GetSinglePaymentNo(HttpContext context)
        {
            var json = _codeBll.GetSinglePaymentNo();
            context.Response.Write(json);
            context.Response.End();
        }
        

        #endregion

        /// <summary>
        /// 及时库存
        /// </summary>
        public void GetInventoryQtyById(HttpContext context)
        {
            try
            {
                var bll = new InventoryBLL();
                var qcmodel = new InventoryQcEntity
                {
                    GoodsId = context.Request["GoodsId"]
                };
                var json = bll.GetInventoryQtyById(qcmodel);
                context.Response.Write(json);
                context.Response.End();
            }
            catch (Exception ex)
            {
                EventsLog.WriteLog("ErrorInfo" + ex.Message);
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}